package chapter08;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CountDownLatch;

@Slf4j
public class CountDownLatchTest {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(4);
        new Thread(()->{latch.countDown();},"t1").start();
        new Thread(()->{latch.countDown();},"t1").start();
        new Thread(()->{latch.countDown();},"t1").start();
        new Thread(()->{latch.countDown();},"t1").start();

        log.debug("waiting....");
        latch.await();
        log.debug("结果：{}",latch.getCount());
    }
}
